package com.theydream.qeechain.main;

import java.util.List;

import android.content.Context;
import android.location.LocationManager;
import android.os.Bundle;

import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.MyLocationOverlay;
import com.google.android.maps.Overlay;
import com.theydream.qeechain.R;

public class SetHome extends MapActivity{
	private MapView mapView;
	private MyLocationOverlay mLocationOverlay;
	private MapController mapController;
	private Context mContext;
	private LocationManager mLocationManager;
	private List<Overlay> mapOverlays;
	
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.set_home_map);
	
	mContext=this;
	//Button btnLocateMe=(Button) findViewById(R.id.btnLocateMe);
	mapView = (MapView) findViewById(R.id.mapview);
	mapView.setBuiltInZoomControls(true);
	mapController = mapView.getController();
	mapOverlays = mapView.getOverlays();
	initMyLocation();
	
	/* Location
	// Register Location Listner to update location
	mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
	//mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,0, 0, this);
	
	// Define a listener that responds to location updates
	LocationListener locationListener = new LocationListener() {
	    public void onLocationChanged(Location location) {
	      // Called when a new location is found by the network location provider.
	     
	    }

	    public void onStatusChanged(String provider, int status, Bundle extras) {}

	    public void onProviderEnabled(String provider) {}

	    public void onProviderDisabled(String provider) {}
	  };

	// Register the listener with the Location Manager to receive location updates
	mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
	*/
	}
	
	private void initMyLocation() {
		mLocationOverlay = new MyLocationOverlay(this, mapView);
		mapOverlays.add(mLocationOverlay);
		mLocationOverlay.runOnFirstFix(new Runnable() {
			public void run() {
				mapController.animateTo(mLocationOverlay.getMyLocation());
			}
		});
	}
	
	@Override
	protected boolean isRouteDisplayed() {
		// TODO Auto-generated method stub
		return false;
	}
	
}
